home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / asmlib35.zip / ASM3DEMO.ZIP / ASMDEMO.ASM < prev    next >
Assembly Source File  |  1993-01-22  |  4KB  |  206 lines

  1. include    asm.inc
  2.  
  3. public    mymain
  4. extrn    syshard:proc, syssoft:proc, runprog:proc
  5. extrn    textdemo:proc, mwdemo:proc
  6. extrn    curvefit:proc, bargraph:proc
  7.  
  8. extrn    pickstr:proc
  9. extrn    pulldown:proc
  10. extrn    tfill:proc, wframe:proc, wclear:proc
  11. extrn    ansicolor:proc, getkey:proc
  12. extrn    screenmem:proc, getscreen:proc, putscreen:proc
  13. extrn    dosalloc:proc
  14. extrn    ansicolor:proc, tclear:proc
  15. extrn    tprint:proc, tprintce:proc, crtinfo:proc
  16. extrn    cursoroff:proc, ucursoron:proc
  17.  
  18. .data
  19. menudata    db 'System',0
  20.         db 'Hardware',0
  21.         db 'Software',0
  22.         db 'Run another program',0
  23.         db 0
  24.         db 'Text mode',0
  25.         db 'Scrolling',0
  26.         db 'Pop-up windows',0
  27.         db 0
  28.         db 'Graphics',0
  29.         db 'Bar Graph',0
  30.         db 'Curve fitting',0
  31.         db 0
  32.         db 'Quit',0
  33.         dw 0
  34.  
  35. text_table    dw textdemo
  36.         dw mwdemo
  37. proc_table    dw demo0
  38.         dw demo1
  39.         dw graphdemo
  40.         dw demo3
  41. sys_table    dw sys_hard
  42.         dw sys_soft
  43.         dw run_program
  44. gdemo_table    dw bar_graph
  45.         dw curve_fit
  46. saved_bx    dw 0
  47. screen_seg    dw 0
  48.  
  49. box_corners    dw 5,5,20,70
  50.  
  51. intro_msg    db ' Welcome to the ASMLIB interactive demonstration program  ',0
  52. intro2_msg    db ' ASMDEMO will give you a few examples of ASMLIB programming ',0
  53. intro3_msg    db ' Note that ASMDEMO has not been optimized, but it will ',0
  54. intro4_msg    db " give you a flavor for some of the library's functions. ",0
  55. intro5_msg    db ' ASMDEMO was written with MASM 5.1 and ASMLIB.  No other ',0
  56. intro6_msg    db ' software tools were used. ',0
  57. press_key    db ' Press any key to continue',0
  58. escape_msg    db ' Press ESC for main menu',0
  59.  
  60. .code
  61. mymain    proc
  62.     call    cursoroff
  63.     call    ansicolor
  64.     mov    al,'░'
  65.     call    tfill
  66.     lea    bx,box_corners
  67.     mov    ah,7
  68.     call    wclear
  69.     mov    al,'■'
  70.     call    wframe
  71.     lea    si,intro_msg
  72.     mov    dh,byte ptr box_corners
  73.     inc    dh
  74.     mov    dl,byte ptr box_corners+2
  75.     inc    dl
  76.     mov    ah,15
  77.     call    tprint
  78.     lea    si,intro2_msg
  79.     inc    dh
  80.     call    tprint
  81.     lea    si,intro3_msg
  82.     inc    dh
  83.     call    tprint
  84.     lea    si,intro4_msg
  85.     inc    dh
  86.     call    tprint
  87.     lea    si,intro5_msg
  88.     inc    dh
  89.     call    tprint
  90.     lea    si,intro6_msg
  91.     inc    dh
  92.     call    tprint
  93.     lea    si,press_key
  94.     add    dh,2
  95.     mov    ah,14
  96.     call    tprint
  97.     call    getkey
  98.  
  99.     xor    bx,bx
  100.     mov    saved_bx,bx
  101. again:    lea    si,menudata
  102.     mov    bx,saved_bx
  103.     call    pulldown
  104.     mov    saved_bx,bx
  105.     cmp    ax,13
  106.     je    demo
  107.     cmp    al,0
  108.     jne    again
  109.  
  110. demo:    mov    bl,bh
  111.     xor    bh,bh
  112.     shl    bx,1
  113.     jmp    proc_table[bx]
  114.  
  115. ;;
  116. ;; SYSTEM demos
  117. ;;
  118. demo0:    mov    bx,saved_bx
  119.     xor    bh,bh        ; BX = submenu index
  120.     shl    bx,1        ; convert to an offset
  121.     jmp    sys_table[bx]
  122. sys_soft:
  123.     call    syssoft
  124.     jmp    again
  125. sys_hard:
  126.     call    syshard
  127.     jmp    again
  128. run_program:
  129.     call    save_screen
  130.     call    runprog
  131.     call    restore_screen
  132.     jmp    again
  133.  
  134. demo1:    mov    bx,saved_bx
  135.     xor    bh,bh
  136.     or    bx,bx
  137.     jz    demo1a
  138.     call    mwdemo
  139.     jmp    again
  140. demo1a:    call    textdemo
  141.     jmp    again
  142.  
  143. ;;
  144. ;; graph mode demos
  145. ;; includes: bargraph, curvefit
  146. ;;
  147. graphdemo:
  148.     call    save_screen
  149. gdemo0:    mov    bx,saved_bx
  150.     xor    bh,bh
  151.     shl    bx,1
  152.     jmp    gdemo_table[bx]
  153.  
  154. curve_fit:
  155.     call    curvefit
  156.     jmp    short gdemo9
  157. bar_graph:
  158.     call    bargraph
  159.  
  160. ; restore text-mode screen
  161. gdemo9:    call    restore_screen
  162.     jmp    again
  163.  
  164. demo3:
  165. exit:    call    ansicolor
  166.     call    tclear
  167.     xor    dx,dx
  168.     call    ucursoron
  169.     ret
  170. mymain    endp
  171.  
  172. save_screen:
  173.     call    screenmem    ; returns screen size in bytes
  174.     xor    dx,dx        ; DX:AX = screen size
  175.     mov    screen_seg,dx    ; default: memory not available
  176.     call    dosalloc    ; allocate memory block
  177.     jc    ss9        ; don't save screen if no memory available
  178.     mov    screen_seg,ax    ; save base address of memory block
  179.  
  180. ; copy screen to memory block
  181.     push    ds
  182.     mov    ds,ax
  183.     xor    si,si
  184.     call    getscreen
  185.     pop    ds
  186.  
  187. ss9:    ret
  188.  
  189. restore_screen:
  190.     mov    ax,screen_seg
  191.     or    ax,ax        ; was screen saved?
  192.     jz    rs9        ;  nope, exit
  193.     push    ds
  194.     mov    ds,ax
  195.     xor    si,si
  196.     call    putscreen
  197.     pop    ds
  198.  
  199. ; release memory block
  200.     mov    es,ax        ; memory block base address
  201.     mov    ah,49h
  202.     int    21h
  203. rs9:    ret
  204.  
  205.     end
  206.